package com.datn.activity;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class CustomListAdapter extends ArrayAdapter<String>{

	


	public CustomListAdapter(Context context, int textViewResourceId,
			ArrayList<String> objects) {
		super(context, textViewResourceId, objects);
		// TODO Auto-generated constructor stub
		this.context=context;
		this.resource=textViewResourceId;
		this.array=objects;
	}


	ArrayList<String> array;
	int resource;
	Context context;
	
	
	


	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return array.size();
	}

	@Override
	public String getItem(int position) {
		// TODO Auto-generated method stub
		return array.get(position);
	}

	
	//-------------------ERROR
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		if (convertView==null) convertView=new CustomItemLayout(getContext());
		String stItem= getItem(position);
		if (stItem!=null){
			TextView tv= ((CustomItemLayout)convertView).tvItem;
			tv.setText(stItem);
			
		}
		
		return convertView;
		
	}
	
	
	
	
}
